class window.BloodParticles extends window.Entity
    constructor : (@number) ->
        @particles = []
        for x in [0..@number]
            @particles.push 
                x : 0
                y : 0
                z : 0
                dx : Math.random() * 2.0 - 1.0
                dy : Math.random() * 2.0 - 1.0
                dz : -Math.random() * 4.0
                life : Math.random() * 75

    update : () ->
        allDead = true
        for p in @particles
            continue if p.life < 0.0
            allDead = false
            p.x += p.dx
            p.y += p.dy
            p.z += p.dz
            p.dz += 0.1
            p.life -= 1.0
        
        if allDead
            @update = () ->



    render : () ->
        for p in @particles
            if p.life < 0.0
                @transform.setTranslation p.x + @x, p.y + @y + p.z
                @g.draw.drawSprite [8 * 16, 4 * 16], @transform
            else
                @transform.setTranslation p.x + @x, p.y + @y + p.z
                @g.draw.drawSprite [7 * 16, 4 * 16], @transform
